<div class="articles index">
    <div id="filtro_busqueda" class="filtro">
        <fieldset>
            <legend>Busqueda</legend>
            <?php echo $form->create('Article', array('url' => array('controller' => 'articles', 'action' => 'index'))); ?>
            <?php
            echo $form->input('marca', array('label' => 'Marca'));
            echo $form->input('modelo', array('label' => 'Modelo'));
            echo $form->submit(__('Buscar', true));
            echo $form->end();
            ?>
        </fieldset>
    </div>
    <h2 class="left"><?php echo $html->image('iconos/articles.png');__('Artículos'); ?></h2>
    <div class="actions specific">
        <ul>
            <li><?php echo $this->Html->link(__('Nuevo Artículo', true), array('controller' => 'articles', 'action' => 'add')); ?> </li>
            <li><?php echo $this->Html->link(__('Artículos Inactivos', true), array('controller' => 'articles', 'action' => 'down')); ?> </li>
<!--            <li><?php echo $this->Html->link(__('Generar Pedidos PDF', true), array('controller' => 'articles', 'action' => 'pedidos')); ?> </li>-->
        </ul>
    </div>
    <div class="clear"></div>
    <table cellpadding="0" cellspacing="0">
        <tr>
<!--            <th><?php echo $this->Paginator->sort('Id', 'id'); ?></th>-->
            <th><?php echo $this->Paginator->sort('Marca', 'mark'); ?></th>
            <th><?php echo $this->Paginator->sort('Modelo', 'model'); ?></th>
            <th><?php echo $this->Paginator->sort('Código', 'code'); ?></th>
            <th><?php echo $this->Paginator->sort('Estilo', 'style'); ?></th>
            <th><?php echo $this->Paginator->sort('Material', 'material'); ?></th>
<!--			<th><?php echo $this->Paginator->sort('Cabezal', 'head'); ?></th>-->
<!--			<th><?php echo $this->Paginator->sort('Detalle', 'detail'); ?></th>-->
            <th><?php echo $this->Paginator->sort('Precio', 'price'); ?></th>
            <th><?php echo $this->Paginator->sort('Stock', 'amount_available'); ?></th>
            <th><?php echo $this->Paginator->sort('Mín Stock', 'min'); ?></th>
<!--			<th><?php echo $this->Paginator->sort('Fecha de Baja', 'termination_date'); ?></th>-->
            <th><?php echo $this->Paginator->sort('Tipo', 'type_id'); ?></th>
<!--                        <th><?php echo $this->Paginator->sort('Imagen', 'image'); ?></th>-->
            <th class="actions"><?php __('Opciones'); ?></th>
        </tr>
        <?php
        $i = 0;
        foreach ($articles as $article):
            $class = null;
            if ($i++ % 2 == 0) {
                $class = ' class="altrow"';
            }
            //me fijo si tiene una cantidad menor que el stock minimo
            if($article['Article']['amount_available'] < $article['Article']['min']){
                $class = ' class="out_stock"';
            }
            ?>
            <tr<?php echo $class; ?>>
    <!--                <td><?php echo $article['Article']['id']; ?>&nbsp;</td>-->
                <td><?php echo $article['Article']['mark']; ?>&nbsp;</td>
                <td><?php echo $article['Article']['model']; ?>&nbsp;</td>
                <td><?php echo $article['Article']['code']; ?>&nbsp;</td>
                <td><?php echo $article['Article']['style']; ?>&nbsp;</td>
                <td><?php echo $article['Article']['material']; ?>&nbsp;</td>
    <!--		<td><?php echo $article['Article']['head']; ?>&nbsp;</td>-->
    <!--		<td><?php echo $article['Article']['detail']; ?>&nbsp;</td>-->
                <td><?php echo '$'.$article['Article']['price']; ?>&nbsp;</td>
                <td><?php echo $article['Article']['amount_available']; ?>&nbsp;</td>
                <td><?php echo $article['Article']['min']; ?>&nbsp;</td>
    <!--		<td><?php echo $article['Article']['termination_date']; ?>&nbsp;</td>-->
                <td>
                    <?php echo $this->Html->link($article['Type']['name'], array('controller' => 'types', 'action' => 'view', $article['Type']['id'])); ?>
                </td>
    <!--		<td><?php echo $article['Article']['image']; ?>&nbsp;</td>                -->
                <td class="actions">
                    <?php echo $this->Html->link(__('Ver', true), array('action' => 'view', $article['Article']['id'])); ?>
                    <?php echo $this->Html->link(__('Pedir', true), array('controller' => 'orders','action' => 'add', $article['Article']['id'])); ?>
                    <?php echo $this->Html->link(__('Editar', true), array('action' => 'edit', $article['Article']['id'])); ?>
                    <?php echo $this->Html->link(__('Dar Baja', true), array('action' => 'baja', $article['Article']['id']), null, sprintf(__('Esta seguro que desea dar baja a # %s?', true), $article['Article']['mark'] . '-' . $article['Article']['model'])); ?>
                    <?php echo $this->Html->link(__('Eliminar', true), array('action' => 'delete', $article['Article']['id']), null, sprintf(__('Esta seguro que desea eliminar el artículo # %s?', true), $article['Article']['mark'] . '-' . $article['Article']['model'])); ?>
                </td>
            </tr>
        <?php endforeach; ?>
    </table>
    <p>
        <?php
        echo $this->Paginator->counter(array(
            'format' => __('Página %page% de %pages%, mostrando %current% registros de %count% en total, a partir del registro %start%, terminando en el %end%', true)
        ));
        ?>	</p>

    <div class="paging">
        <?php echo $this->Paginator->prev('<< ' . __('anterior', true), array(), null, array('class' => 'disabled')); ?>
        | 	<?php echo $this->Paginator->numbers(); ?>
        |
        <?php echo $this->Paginator->next(__('siguiente', true) . ' >>', array(), null, array('class' => 'disabled')); ?>
    </div>
</div>